## ─ Attaching packages ──────────────────────────── tidyverse 1.2.1 ─
## ✔ ggplot2 2.2.1 ✔ purrr 0.2.4
## ✔ tibble 1.4.2 ✔ dplyr 0.7.4
## ✔ tidyr 0.8.0 ✔ stringr 1.2.0
## ✔ readr 1.1.1 ✔ forcats 0.2.0
## Warning: package 'tibble' was built under R version 3.4.3
## Warning: package 'tidyr' was built under R version 3.4.3
## ─ Conflicts ───────────────────────────── tidyverse_conflicts() ─
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
is.tibble(mtcars)
## [1] FALSE
So, if we can open the data.frame with tibble, then it’s a tibble data.frame. If we have to open it with as_tibble(), then it is a regular data.frame. And also, we can use is.tibble() to find out if it is a tibble or just a normal data.frame.
## [1] a
## Levels: a
## [1] a
## Levels: a
if we want to subset some data from regular data.frame, we have to consider about the rows and columns. However, if we use tibble, we could just consider the columns. ##10.5.3
var <- “mpg” var[[“mpg”]] var %>% .$mpg var %>% .[[“mpg”]]
## [1] 1 2 3 4 5 6 7 8 9 10
enframe() converts named atomic vectors or lists to two-column data frames. For unnamed vectors, the natural sequence is used as name column.
print.tbl_df
we use na.rm = T in this case is reasonable, because there are lots of NA values in the data which is useless. we can use count(cases=NA) find out the all these missing values.
count(who,cases = NA)
The code will not be separated properly into the three columns new, var, and sexage.